import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './theme/index.css'
import App from './App.vue'
import router from './router'
import VueClipboard from 'vue-clipboard2'
import axios from "axios";
import VueAxios from "vue-axios";
import moment from "moment"
Vue.prototype.$moment = moment;

Vue.use(VueAxios, axios)
Vue.use(VueClipboard)
Vue.use(ElementUI);
Vue.prototype.baseUrl = 'http://localhost:8082/'
Vue.config.productionTip = false

// var token = window.sessionStorage.getItem('token')
// if(token !== null){
//   this.timer = setInterval(() => {
//     // 发送在线信息2分钟一次
//     axios.get(Vue.prototype.baseUrl + 'user/addTime')
//         .then(res => {
//           console.log(res)
//         })
//   }, 10000)
// }
axios.interceptors.request.use(config => {
  // Initialize an agent at application startup.
  //在请求头中设置 Authorazation
  var token = window.sessionStorage.getItem('token')
  if(token !== null){
    config.headers.token = window.sessionStorage.getItem('token')

  }
  return config
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
